const express = require("express")
const router = express.Router()
const handler = require("./handler/vod")
const multer = require('multer')
const path = require('path')
const expressJoi = require('@escook/express-joi')
const { add_teacher } = require("../schema/vod")

// 创建文件上传的处理器
const upload = multer({
  dest: path.join(__dirname, '../public/upload/avatar'),
})

// 查询讲师列表
router.post('/vod/teacher/findQueryPage/:page?/:pageSize?/', handler.handlerFindQueryPage)

// 添加讲师
router.post('/vod/teacher/saveTeacher', expressJoi(add_teacher), handler.handlerSaveTeacher)

// 讲师头像上传
router.post('/admin/vod/file/upload',upload.single('file'), handler.handlerUpload)

// 根据id查询讲师
router.get('/vod/teacher/getTeacher/:id', handler.handlerFindById)

// 更新讲师
router.post('/vod/teacher/updateTeacher', handler.handlerUpdateTeacher)

// 删除讲师
router.delete('/vod/teacher/remove/:id', handler.handlerDeleteTeacher)

// 批量删除讲师
router.delete('/vod/teacher/removeBatch', handler.handlerDeleteTeacherBatch)

// 查询所有讲师
router.get('/vod/teacher/findAll', handler.handlerFindAll)


module.exports = router

